<%-- 
    Document   : pertanyaan_tawaran_haji
    Created on : Aug 9, 2012, 9:31:25 AM
    Author     : faizal.azlee(Theta-Edge Bhd)
--%>
<%@ include file="/WEB-INF/jsp/include/page_header.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Pendaftaran Haji</title>
        <script type="text/javascript">
            $(document).ready(function(){
                $('form').submit( function () {
                    return formValidation();
                }); 
                $('.1').hide();
                
                /*
                 * hide or show tahun peruntukan based 
                 * statusTawaran if P101 : boleh pilih tahun peruntukan
                 * other (P102,P106,P107) : tak boleh pilih
                 */
                var status = "${actionBean.haji.statusTawaran}";
                if (status == "P101") {
                    $('.special').hide();
                } else {
                    $('.basic').hide();
                }
                
                addCombo();
            });
            
            
                //combo box
                   function addCombo() {
                        var tahunTawaranHajiHijrah="${actionBean.haji.tahunTawaranHijrah}";
                        var tahunTawaranHaji="${actionBean.haji.tahunTawaran}";
                        var yearArray = [];
                        var opt = [];
                        //var firstyearHijri = '1434';
                       // var firstyearMasihi = '2013';
                        var firstyearHijri = tahunTawaranHajiHijrah;
                        var firstyearMasihi = tahunTawaranHaji;
                        var v_temp;
                        var combo = document.getElementById("tahunpilihanbaru");

                        var Lblchange = document.getElementById("val_masihi");
                        Lblchange.innerHTML = "H/ 2014M";


                        for (var i = 1; i <= 50; i++) {
                            firstyearHijri = parseInt(firstyearHijri) + 1;
                            firstyearMasihi = parseInt(firstyearMasihi) + 1;

                            yearArray[i] = firstyearHijri.toString() + "/" + firstyearMasihi.toString()
                        }

                        for (var i = 1; i <= yearArray.length; i++) {
                            var option = document.createElement("option");
                            opt = yearArray[i].toString().split('/');

                            option.textContent = opt[0].toString();
                            option.value = opt[1].toString();
                            combo.appendChild(option);
                        }
                 }

                 function changeIndex() {
                        var DDchange = document.getElementById("tahunpilihanbaru");
                        var Lblchange = document.getElementById("val_masihi");
                        Lblchange.innerHTML = "H/ " + DDchange.value.toString() + "M";
                 }
                
                
            function goBack()
            {
                window.history.back();
            }
            function doSelect(val)
            {
                if(val=="")
                    {
                        $('.1').show();
                    }
                 else
                     {
                         $('.1').hide();
                     }
            }
            function nrmlyr(val)
            {
                $.get('${pageContext.request.contextPath}/year/' + val +'?normalYear',function(data){
                    document.getElementById("yr").innerHTML=data;
                   }); 
//                   $.ajax({
//                            url: url,
//                            dataType: "text",
//                            success: function( data ) {      
//                                alert(data);
//                            }
//                        });
            }
            
            function redirectBack(f){
            var url = '${pageContext.request.contextPath}/haji?showJawabTawaran';
            f.action = url;
            f.submit();
        }
    </script>
    </head>
    <body>
        <s:messages/>
        <s:errors/> 
        <br/>
        <s:useActionBean beanclass="th.stripes.util.ListUtil" id="listUtil" />
        <s:form beanclass="th.stripes.action.HajiResponseActionBean" class="niceform">
            <div id="content">
                <div id="logo">
                    <span>
                        <img src="${pageContext.request.contextPath}/images/img/ribbon.png"/>               
                    </span>
                </div>
                <h3>
                    Jawab Tawaran Tunai Haji
                </h3>
                <p>
                    <label>Nama :</label>
                        ${actionBean.haji.mohonMaklumat.nama}
                        <s:hidden name="haji.mohonMaklumat.nama"></s:hidden>
                </p>
                <p>
                    <label>No. Akaun TH :</label>
                        ${actionBean.haji.mohonMaklumat.noAkaun}
                        <s:hidden name="haji.mohonMaklumat.noAkaun"></s:hidden>
                </p>
                <p>
                    <label>No. KP Semasa :</label>
                        ${actionBean.haji.mohonMaklumat.noPengenalan}
                        <s:hidden name="haji.mohonMaklumat.noPengenalan"></s:hidden>
                </p>
                <p>
                    Anda Telah memilih untuk menolak tawaran ini. Sila isikan maklumat di bawah
                </p>
                    <p>
                    <label>Alasan menolak tawaran :</label>
                    <s:select name="haji.alasantolak" onchange="doSelect(this.value)"  >
                        <c:forEach items="${listUtil.alasanKeySeq}" var="item">
                            <s:option value="${item.substring(0,2)}">${item.toString()}</s:option>
                        </c:forEach>
                        <s:option value="">Lain-lain</s:option>
                    </s:select>
                </p>
                <div class="1">
                <p>
                    <label>Lain-lain(Nyatakan) :</label>
                    <s:textarea name="haji.alasanlain"  id="alasanlain"></s:textarea>
                </p>
                </div>
                <div class="basic">
                    <p> 
                        <label>Tahun peruntukan baru :</label>
                        <select name="haji.tahunpilihanbaru" class="required" id="tahunpilihanbaru" onchange="changeIndex()">
                        </select><span id="val_masihi"></span>

                    </p>
                </div>
                <div class="special">
                    <p> 
                        <label>Tahun peruntukan :</label>
                        ${actionBean.haji.tahunTawaranHijrah}H/ ${actionBean.haji.tahunTawaran}M

                    </p>
                </div>    
                <p align="center">
                    <s:button name="back" value="Kembali" class="button green" onclick="redirectBack(this.form);"/>
                    <s:submit name="HajjResp_Step6"  value="Hantar" class="button green"/>                                                
                </p>          
            </div>
        </s:form>
    </body>
</html>
